package com.example.zsydb.entity;

//import javax.persistence.*;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.Table;

import java.time.LocalDateTime;
import java.util.Locale;

@Entity
@Table(name = "GSFW_GTLY_RESULT")
public class GtlyResult {
    @Id
    @Column(name = "ID")
    private Long id;

    //井号
    @Column(name = "JH")
    private String jh;

    //作业区
    @Column(name = "KM")
    private String km;

    //功图时间
    @Column(name = "CHECK_DATE")
    private LocalDateTime checkDate;

    //动液面
    @Column(name = "DYM")
    private String dym;

    //产液量
    @Column(name = "CYL_GTMJ")
    private String cylGtmj;

    //工况诊断
    @Column(name = "GKZD")
    private String gkzd;

    //队号
    @Column(name = "DM")
    private String dm;

    //采油方式
    @Column(name = "CYFS")
    private String cyfs;

    //测试日期
    @Column(name = "CSRQ")
    private LocalDateTime csrq;

    //泵径
    @Column(name = "BJ")
    private String bj;

    //含水
    @Column(name = "HS")
    private String hs;

    //泵深
    @Column(name = "BS")
    private String bs;



    //实测最大载荷
    @Column(name = "XDZDZH")
    private String xdzdzh;

    //实测最小载荷
    @Column(name = "XDZXZH")
    private String xdzxzh;

    //实测冲程
    @Column(name = "CC")
    private String cc;

    //实测冲次
    @Column(name = "CC1")
    private String cc1;



    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

    public String getJh() { return jh; }
    public void setJh(String jh) { this.jh = jh; }

    public String getKm() { return km; }
    public void setKm(String km) { this.km = km; }

    public LocalDateTime getCheckDate() { return checkDate; }
    public void setCheckDate(LocalDateTime checkDate) { this.checkDate = checkDate; }

    public String getDm() { return dm; }
    public void setDm(String dm) { this.dm = dm; }

    public String getCyfs() { return cyfs; }
    public void setCyfs(String cyfs) { this.cyfs = cyfs; }

    public LocalDateTime getCsrq() { return csrq; }
    public void setCsrq(LocalDateTime csrq) { this.csrq = csrq; }

    public String getBj() { return bj; }
    public void setBj(String bj) { this.bj = bj; }

    public String getHs() { return hs; }
    public void setHs(String hs) { this.hs = hs; }

    public String getBs() { return bs; }
    public void setBs(String bs) { this.bs = bs; }

    // 新增逻辑方法供前端调用
    public String getDymDisplay() {
        if (dym == null) {
            return "";
        }
        try {
            double number = Double.parseDouble(dym);
            // 格式化为两位小数（英文格式，避免逗号/小数点问题）
            return String.format(Locale.ENGLISH, "%.2f", number);
        } catch (NumberFormatException e) {
            return dym; // 非数字返回原值
        }
    }
    public void setDym(String dym) { this.dym = dym; }

    public String getXdzdzh() { return xdzdzh; }
    public void setXdzdzh(String xdzdzh) { this.xdzdzh = xdzdzh; }

    public String getXdzxzh() { return xdzxzh; }
    public void setXdzxzh(String xdzxzh) { this.xdzxzh = xdzxzh; }

    public String getCc() { return cc; }
    public void setCc(String cc) { this.cc = cc; }

    public String getCc1() { return cc1; }
    public void setCc1(String cc1) { this.cc1 = cc1; }

//    public String getCylGtmj() { return cylGtmj; }
    public String getCylGtmjDisplay() {
        if (cylGtmj == null) {
            return "";
        }
        try {
            double number = Double.parseDouble(cylGtmj);
            // 格式化为两位小数（英文格式，避免逗号/小数点问题）
            return String.format(Locale.ENGLISH, "%.2f", number);
        } catch (NumberFormatException e) {
            return cylGtmj; // 非数字返回原值
        }
    }
    public void setCylGtmj(String cylGtmj) { this.cylGtmj = cylGtmj; }

    public String getGkzd() { return gkzd; }
    public void setGkzd(String gkzd) { this.gkzd = gkzd; }
}
